Flushes any pending writes and closes the writer.
Syntax
Visual Basic (Declaration) | |
---|
Public Sub Close() |
Example
BPlusTree/BPlusTree.Test/TestTransactionLog.cs
C# | Copy Code |
---|
using (TempFile tmp = new TempFile())
{
var opts = Options(tmp);
using (var log = new TransactionLog<int, string>(opts))
{
var token = log.BeginTransaction();
log.AddValue(ref token, 1, "test");
log.CommitTransaction(ref token);
token = log.BeginTransaction();
log.AddValue(ref token, 2, "test");
log.CommitTransaction(ref token);
token = log.BeginTransaction();
log.AddValue(ref token, 3, "test");
log.CommitTransaction(ref token);
log.Close();
}
using (var log = new TransactionLog<int, string>(opts))
{
var test = new Dictionary<int, string>();
log.ReplayLog(test);
Assert.AreEqual(3, test.Count);
for (int i = 1; i <= 3; i++)
Assert.AreEqual("test", test[i]);
}
} |
VB.NET | Copy Code |
---|
Using tmp As New TempFile()
Dim opts As var = Options(tmp)
Using log As var = New TransactionLog(Of Integer, String)(opts)
Dim token As var = log.BeginTransaction()
log.AddValue(token, 1, "test")
log.CommitTransaction(token)
token = log.BeginTransaction()
log.AddValue(token, 2, "test")
log.CommitTransaction(token)
token = log.BeginTransaction()
log.AddValue(token, 3, "test")
log.CommitTransaction(token)
log.Close()
End Using
Using log As var = New TransactionLog(Of Integer, String)(opts)
Dim test As var = New Dictionary(Of Integer, String)()
log.ReplayLog(test)
Assert.AreEqual(3, test.Count)
Dim i As Integer = 1
While i <= 3
Assert.AreEqual("test", test(i))
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
End Using
End Using |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also